<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>平台详情</title>
        <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
        <link rel="stylesheet" href="./css/platDetail.css">
        <script src="./js/cookie.js"></script>
        <script src="http://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
    </head>
    <body>
        <div id="box" v-cloak>
            <header>合作平台详情</header>
            <div class="contents">
                <div class="name">
                    <span v-show="allData">{{allData.COMPNAME}}</span>
                </div>
                <div class="detailInfo">
                    <table>
                        <tr>
                            <td>
                                <span>公司名称</span>
                                <input type="text" v-model.trim="input1" style="margin-top:20px;"/>
                            </td>
                            <td style="display:none;">
                                <span class="secondSpan"></span>
                                <input type="text" v-model.trim="input4"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>商户号</span>
                                <input type="text" v-model.trim="input3" disabled="disabled"/>
                            </td>
                            <td>
                                <span class="secondSpan">收款方全称</span>
                                <input type="text" v-model.trim="input4"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>创建时间</span>
                                <input type="text" v-model.trim="input5" disabled="disabled"/>
                            </td>
                            <td>
                                <span class="secondSpan">开户银行</span>
                                <input type="text" v-model.trim="input6"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>联系人</span>
                                <input type="text" v-model.trim="input7"/>
                            </td>
                            <td>
                                <span class="secondSpan">银行账号</span>
                                <input type="text" v-model.trim="input8"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>联系电话</span>
                                <input type="text" v-model.trim="input9"/>
                            </td>
                            <td>
                                <span class="secondSpan">业务对接人</span>
                                <input type="text" v-model.trim="input13"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>结算比率</span>
                                <input type="text" v-model.trim="input10"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="line1"></div>
                            </td>
                            <td>
                                <div class="line2"></div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>登录账号</span>
                                <input type="text" v-model.trim="input11" disabled="disabled"/>
                            </td>
                            <td>
                                <span class="secondSpan">登录密码</span>
                                <input type="text" v-model.trim="input12"/>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <footer>
                <button class="modify" @click="modify">保存修改</button>
                <button class="cancel" @click="cancel">取消关闭</button>
            </footer>
        </div>
    </body>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue-resource@1.3.5"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script>
var vm = new Vue({
    el: '#box',
    data: {
        //getIp1: 'http://192.168.0.180:8085/CARSERV', //测试环境ip
        //getIp1: 'http://carnt.carnettong.com:8088/CARSERV', //正式环境ip
        getIp1: 'http://121.40.78.200:88/CARSERV',
        iid: '', //平台ID
        allData: '', //平台所有数据
        input1: '', //公司名称
        input2: '', //收款银行
        input3: '', //商户号
        input4: '', //收款方全称
        input5: '', //创建时间
        input6: '', //开户银行
        input7: '', //联系人
        input8: '', //银行账号
        input9: '', //联系电话
        input10: '', //结算比率
        input11: '', //登录账号
        input12: '', //登录密码
        input13: '', //业务对接人
        once:true,//防止重复提交
    },
    created: function () {
        let test = window.location.href;
        if (test.indexOf('?') < 0 || test.indexOf('id') < 0) {
            location.href = './cooperationPlat.html';
            return;
        }
        let arr = test.split('?');
        let new_arr = arr[1].split('=');
        this.iid = new_arr[1];
        //合作平台详情
        this.$http.post(this.getIp1 + '/PlatformUser/platformUserDetail.action', {ID: this.iid}, {emulateJSON: true}).then(
                res => {
                    this.allData = res.body;
                    this.input1 = res.body.COMPNAME;
                    this.input2 = res.body.BANKNAME;
                    this.input3 = res.body.PLATFORMNO;
                    this.input4 = res.body.BANKPAYEE;
                    this.input5 = this.format(res.body.CREATETIME);
                    this.input6 = res.body.BANKACCOUNT;
                    this.input7 = res.body.CONTACT;
                    this.input8 = res.body.BANKADR;
                    this.input9 = res.body.PHONE;
                    this.input10 = res.body.RATIO;
                    this.input11 = res.body.LOGINNAME;
                    this.input12 = res.body.LOGINPWD;
                    this.input13 = res.body.CARNTCONTACT;
                }, err => console.log(err)
        );

    },
    computed: {

    },
    methods: {
        //时间格式化
        format: function (val) {
            var y = new Date(val).getFullYear();
            var m = new Date(val).getMonth() + 1 >= 10 ? new Date(val).getMonth() + 1 : '0' + (new Date(val).getMonth() + 1);
            var d = new Date(val).getDate() >= 10 ? new Date(val).getDate() : '0' + new Date(val).getDate();
            var h = new Date(val).getHours() >= 10 ? new Date(val).getHours() : '0' + new Date(val).getHours();
            var ms = new Date(val).getMinutes() >= 10 ? new Date(val).getMinutes() : '0' + new Date(val).getMinutes();
            return y + "-" + m + "-" + d + " " + h + ":" + ms;
        },
        //小数换算百分数
        percentage(val){
            let b = (val * 100).toFixed(2) + "%";
            if(val.match('%')){
                return val;
            }else{
                return b;
            }
        },
        //保存修改
        modify() {
            let obj = {};
            obj.ID = this.iid;
            obj.COMPNAME = this.input1;
            obj.PLATFORMNO = this.input3;
            obj.CREATETIME = this.input5;
            obj.CONTACT = this.input7;
            obj.PHONE = this.input9;
            obj.RATIO = this.input10;
            obj.BANKNAME = this.input2;
            obj.BANKPAYEE = this.input4;
            obj.BANKACCOUNT = this.input6;
            obj.BANKADR = this.input8;
            obj.LOGINNAME = this.input11;
            obj.LOGINPWD = this.input12;
            if(this.once){
                this.once = false;
                //编辑合作平台
                this.$http.post(this.getIp1 + '/PlatformUser/savePlatformUser.action', obj, {emulateJSON: true}).then(
                        res => {
                            if (res.body.STATUC_CODE == 1) {
                                //合作平台详情
                                this.$http.post(this.getIp1 + '/PlatformUser/platformUserDetail.action', {ID: this.iid}, {emulateJSON: true}).then(
                                        res => {
                                            this.allData = res.body;
                                            this.input1 = res.body.COMPNAME;
                                            this.input2 = res.body.BANKNAME;
                                            this.input3 = res.body.PLATFORMNO;
                                            this.input4 = res.body.BANKPAYEE;
                                            this.input5 = this.format(res.body.CREATETIME);
                                            this.input6 = res.body.BANKACCOUNT;
                                            this.input7 = res.body.CONTACT;
                                            this.input8 = res.body.BANKADR;
                                            this.input9 = res.body.PHONE;
                                            this.input10 = res.body.RATIO;
                                            this.input11 = res.body.LOGINNAME;
                                            this.input12 = res.body.LOGINPWD;
                                        }, err => console.log(err)
                                );
                                //消息提示
                                this.$alert('修改成功!', '提示',{
                                    showClose:false,
                                    showConfirmButton:false
                                });
                                setTimeout(function(){location.href="./cooperationPlat.html"},1000);
                            }
                        }, err => console.log(err)
                );
            }
        },
        //取消关闭
        cancel() {
            history.back();
        },
    },
    filters: {

    },
});
    </script>
</html>
